package com.example.administrator.yuejian_15.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.JlbSpAdapter;
import com.example.administrator.yuejian_15.bean.JlbSpBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.JlbSpModel;

import java.util.List;

public class JlbSpActivity extends BaseActivity implements View.OnClickListener{

    ImageView sp_fh;
    RecyclerView rv_splist;
    List<JlbSpBean> items;
    String jlbid;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_jlb_sp);
        sp_fh = (ImageView)findViewById(R.id.sp_fh);
        rv_splist=(RecyclerView)findViewById(R.id.rv_splist);
        jlbid=getIntent().getStringExtra("jlbid");
        JlbSpModel jlbSpModel = new JlbSpModel();
        jlbSpModel.getSpList(jlbid,jlbSpBeanListListener);
    }

    @Override
    void initEvent() {
        sp_fh.setOnClickListener(this);

    }

    @Override
    void initDate() {
        sp_fh.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.sp_fh:
                finish();
                break;
        }

    }

    ListListener<JlbSpBean> jlbSpBeanListListener = new ListListener<JlbSpBean>() {
        @Override
        public void onResponse(List<JlbSpBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(JlbSpActivity.this);
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_splist.setLayoutManager(linearLayoutManager);
            items=list;
            JlbSpAdapter jlbSpAdapter=new JlbSpAdapter(JlbSpActivity.this,items,R.layout.item);
            rv_splist.setAdapter(jlbSpAdapter);
            rv_splist.setItemAnimator(new DefaultItemAnimator());

        }

        @Override
        public void onFail(String msg) {

        }
    };
}
